﻿class TextViewController implements ITextViewDelegate
{
    textView: TextView;
    doc: TextDocument;

    constructor()
    {
        this.textView = new TextView();
        this.textView.delegate = this;
        this.doc = new TextDocument();
        document.body.appendChild(this.textView.view);
        this.textView.view.focus();
    }

    appendTextLinesAtPosition(text: string, position: TextPosition):TextPosition
    {
        return this.doc.appendTextLinesAtPosition(text, position);
    }

    deleteTextWithRange(range: TextSelectionRange):TextPosition
    {
        return this.doc.deleteTextWithRange(range);
    }

    lineCount(): number
    {
        return this.doc.lineCount();
    }

    lineLength(line: number): number
    {
        return this.doc.lineLength(line);
    }

    getLineText(line: number): string
    {
        return this.doc.getLineText(line);
    }
}